# Maintainer: David Runge <dvzrv@archlinux.org>

_name=Mellite
_app_name=de.sciss.mellite.Mellite
pkgname=mellite
pkgver=3.13.4
pkgrel=1
pkgdesc="An environment for creating experimental computer-based music and sound art"
arch=(any)
url="https://www.sciss.de/mellite/"
license=(AGPL3)
groups=(pro-audio)
depends=('java-environment>=16' supercollider)
makedepends=(gendesk sbt)
source=(
  $pkgname-$pkgver.tar.gz::https://github.com/Sciss/$pkgname/archive/refs/tags/v$pkgver.tar.gz
  $pkgname.sh
)
sha512sums=('4618d1fbff0ceb2035bafd9f44674cc36f8664f7e06621b208ae3269a64914c0ac540b217b72c01912287b4bcbc5d555ef30cd785345b76d7499d4299d6c3f7d'
            '1a6a572b4c365cdad87930bef805afa229b329cb2ceefb6b9ce42b233ab86f768ae3e3d5fd7cac1129786878c38fd891015aaf6637d9bd7b5ce3b2ef5fe9d30b')
b2sums=('c61c61031cfaf928d5b73b7377379a200f8cfe4d10eb056a1bb8590b97484dc197a4058b5d81d279b8eeb2b4ceb0c23d3bc2ea5d8b4843b8c4f47a289e551202'
        '4f1fd83d7cf5561e76f746860e5436e7dfab9bd50ad103f499b82de99a67034122f0e8e99e6a58574d6611585d63b2976e5d31979c7233294464683c86cce3ea')

prepare() {
  gendesk -n \
          --pkgname "$_app_name" \
          --name "Mellite" \
          --pkgdesc "${meter_types[$type]}" \
          --exec "$pkgname" \
          --icon "$_app_name" \
          --genericname "Audio Programming" \
          --categories "AudioVideo;Audio"
}

build() {
  cd $_name-$pkgver
  sbt +mellite-app/test +mellite-app/assembly
}

package() {
  install -vDm 644 $_name-$pkgver/app/$_name.jar -t "$pkgdir/usr/share/scala/$pkgname"
  install -vDm 644 $_name-$pkgver/icons/application.png "$pkgdir/usr/share/icons/hicolor/256x256/apps/de.sciss.mellite.Mellite.png"
  install -vDm 644 $_name-$pkgver/icons/application.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/de.sciss.mellite.Mellite.svg"

  install -vDm 755 $pkgname.sh "$pkgdir/usr/bin/$pkgname"
  install -vDm 644 *.desktop -t "$pkgdir/usr/share/applications/"
}
